﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability_Management.Domain;
using Traceability_Management.ErrorCode;
using Traceability_Management.Read.Api.Application.Command.HealthyWay;
using Traceability_Management.Read.Api.Application.Command.RabitsWay;
using Traceability_Management.Read.Api.Dto;

namespace Traceability_Management.Read.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RabitsAllController : ControllerBase
    {
        IMediator mediator;

        public RabitsAllController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        [HttpPost]
        public async Task<ApiResult<int>> AddRaibts(Rabits Rabits)
        {
            try
            {
                AddRabitsCommand AddRabitsCommand = new AddRabitsCommand()
                {
                    Rabits = Rabits
                };
                return await mediator.Send(AddRabitsCommand);
            }
            catch (Exception)
            {

                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<List<RabitDto>>> ShowRaibts([FromQuery] ShowRabitsCommand ShowRabitsCommand)
        {
            try
            {
                return await mediator.Send(ShowRabitsCommand);
            }
            catch (Exception)
            {

                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<int>> DelRaibts(int id)
        {
            try
            {
                DelRabitsCommand DelRabitsCommand = new DelRabitsCommand()
                {
                    id = id
                };
                return await mediator.Send(DelRabitsCommand);
            }
            catch (Exception)
            {

                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<List<Shop_Table>>> ShowShop([FromQuery] ShowShopCommand ShowShopCommand)
        {
            try
            {
                return await mediator.Send(ShowShopCommand);
            }
            catch (Exception)
            {

                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<Rabits>> FirstRabits([FromQuery] FirstRabitsCommand FirstRabitsCommand)
        {
            try
            {
                return await mediator.Send(FirstRabitsCommand);
            }
            catch (Exception)
            {

                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<int>> DelAllRabits([FromQuery]DelAllRabitsCommand request)
        {
            try
            {

                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        [HttpPost]
        public async Task<ApiResult<int>> EditRaibts(Rabits Rabits)
        {
            try
            {
                UpdateRabitsCommand UpdateRabitsCommand = new UpdateRabitsCommand() 
                {
                    Rabits = Rabits
                };

                return await mediator.Send(UpdateRabitsCommand);
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<string>> BathShow( [FromQuery]BatchShowCommand request)
        {
            try
            {
                 return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<int>> UpdateCheckImages( [FromQuery]UpdateCheckImagesCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }


    }
}
